package com.conceal.client.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.conceal.client.service.ConcealWxOnlineMatchingService;
/**
 * 定时查看在线匹配队列，超时，直接匹配机器
 * @author Administrator
 *
 */

@Component
public class CheckMatchTimedTask {
	 @Autowired
     ConcealWxOnlineMatchingService concealWxOnlineMatchingService;
	 protected static Logger log = Logger.getLogger(CheckMatchTimedTask.class);
	 /**
     * 首次延时20s等待配置加载完成，然后每10秒执行一次
     */
    @Scheduled(initialDelay = 10000,fixedRate = 10000)
	 public void task() {
    	String overtimeMatching = concealWxOnlineMatchingService.checkMatchTimedTask();
    	if(overtimeMatching!=null) {
    		String[] strPid = overtimeMatching.split(",");
        	for(int i=0;i<strPid.length;i++) {
        		WxWebSocket.onSend(strPid[i], "3002,10001");
        	}
    	}
    	
	 }
	 
}
